Skip to content

fix: allow clientSecretCertificateKeyVaultReference in AAD auth schema (#944)#993

Open
LongOddCode wants to merge 1 commit intoAzure:mainfrom
LongOddCode:developer/LongOddCode/schema-cert-auth-ref
Open

fix: allow clientSecretCertificateKeyVaultReference in AAD auth schema (#944)#993
LongOddCode wants to merge 1 commit intoAzure:mainfrom
LongOddCode:developer/LongOddCode/schema-cert-auth-ref

Conversation

@LongOddCode
Copy link
Copy Markdown
Contributor

Problem

Issue #944: swa deploy rejects the documented cert-based AAD custom-auth configuration with a schema validation error. The shape is published on Microsoft Learn (Custom authentication in Azure Static Web Apps) and uses clientSecretCertificateKeyVaultReference, but the CLI's staticwebapp.config.json schema does not allow it.

Root Cause

In schema/staticwebapp.config.json the azureActiveDirectory.registration object:

  1. Declares clientSecretSettingName as unconditionally required.
  2. Does not define clientSecretCertificateKeyVaultReference as an allowed property, so additionalProperties: false rejects it.

Both conditions together make the cert-based shape invalid. Maintainer @Timothyw0 confirmed on the issue that this exact file + line is where the change belongs.

Fix

File Change
schema/staticwebapp.config.json Add clientSecretCertificateKeyVaultReference property; relax required to ["openIdIssuer"]; add oneOf that requires exactly one of clientSecretSettingName or clientSecretCertificateKeyVaultReference.

The oneOf preserves the original intent — a credential must still be configured — while permitting either credential shape. additionalProperties: false is kept so unknown keys still fail validation.

Testing

  • ✅ Existing shape with clientSecretSettingName still validates (covered by oneOf branch 1).
  • ✅ New shape with clientSecretCertificateKeyVaultReference now validates (covered by oneOf branch 2).
  • ✅ Missing both credentials fails validation (oneOf requires exactly one).
  • ✅ Providing both credentials fails validation (oneOf rejects matches on both branches) — this is desirable because they are mutually exclusive at the platform level.
  • ✅ Existing description text preserved; only the clientSecretSettingName description was extended to clarify mutual exclusion.

References

Azure#944)

The staticwebapp.config.json schema for azureActiveDirectory.registration required clientSecretSettingName and did not allow clientSecretCertificateKeyVaultReference, causing 'swa deploy' to reject the documented cert-based auth shape (see Microsoft Learn: Custom authentication in Azure Static Web Apps).  Changes: - Add clientSecretCertificateKeyVaultReference property. - Remove clientSecretSettingName from unconditional 'required'. - Add oneOf requiring exactly one of the two credentials, so validation still enforces that a credential is configured.  Guidance from @Timothyw0 on the issue pointed to this exact schema location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom Cert Authentication not working with SWA deploy

1 participant